// fetchPage.js
const axios = require('axios');

async function fetchPage(url, retries = 3) {
  try {
    const response = await axios.get(url, {
      timeout: 10000,
      // proxy 或代理配置根据需要添加
    });
    return response.data;
  } catch (err) {
    if (retries > 0) {
      await new Promise(resolve => setTimeout(resolve, 1000));
      return fetchPage(url, retries - 1);
    } else {
      console.error('请求失败:', url);
      return null;
    }
  }
}

module.exports = fetchPage;
